package javacode.chapter04;

import java.util.Scanner;

public class Example4_6 {
    public static void main(String[] args) {
        //根据输入年份和月份确定该月的天数
        int year;
        int month;
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入年月（以空格分隔）：");
        year = scanner.nextInt();
        month = scanner.nextInt();
        int days;

        switch (month) {
            case 2:
                if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
                    days = 29;
                } else {
                    days = 28;
                }
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                days = 30;
                break;
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                days = 31;
                break;
            default:
                days = 0;
                System.out.println("你输入的月份错误！");
        }

        System.out.println(year + "年" + month + "月有" + days + "天！");
    }
}
